/*
 * MediaChooserConstants.java
 * classes : com.ruint.lib.mediachooser.core.MediaChooserConstants
 * @author ruint
 * V 1.0.0
 * Create at 2014-12-4 下午3:00:27
 */
package com.ruint.lib.mediachooser.core;

import java.io.File;

import android.content.IntentFilter;

import com.ruint.core.utils.preferences.CorePreferences;

/**
 * com.ruint.lib.mediachooser.core.MediaChooserConstants
 * 
 * @author ruint <br/>
 *         create at 2014-12-4 下午3:00:27
 */
public class MediaChooserConstants {
  /**
   * folder name on which captured photo & video are saved on sd card.
   */
  public static String folderName = CorePreferences.getAppImageSDPath();

  public static final String MEDIA_SELECTED_LIST = "MEDIA_SELECTED_LIST";
  public static final String MEDIA_FILE_PATH = "MEDIA_FILE_PATH";

  /**
   * No of item that can be selected. Default is 0.
   */
  public static int MAX_MEDIA_LIMIT = 0;

  /**
   * Selected media file count.
   */
  public static int SELECTED_MEDIA_COUNT = 0;

  public static boolean showCameraVideo = true;
  public static boolean showVideo = true;
  public static boolean showImage = true;

  public static int SELECTED_IMAGE_SIZE_IN_MB = 20;
  public static int SELECTED_VIDEO_SIZE_IN_MB = 20;

  public static final int BUCKET_SELECT_IMAGE_CODE = 1000;
  public static final int BUCKET_SELECT_VIDEO_CODE = 2000;

  public static final int MEDIA_TYPE_IMAGE = 1;
  public static final int MEDIA_TYPE_VIDEO = 2;

  public static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
  public static final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 200;

  public static long ChekcMediaFileSize(File mediaFile, boolean isVideo) {

    /** Get length of file in bytes */
    long fileSizeInBytes = mediaFile.length();

    /** Convert the bytes to Kilobytes (1 KB = 1024 Bytes) */
    long fileSizeInKB = fileSizeInBytes / 1024;

    /** Convert the KB to MegaBytes (1 MB = 1024 KBytes) */
    long fileSizeInMB = fileSizeInKB / 1024;

    int requireSize = 0;
    if (isVideo) {
      requireSize = MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB;
    } else {
      requireSize = MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB;
    }
    if (fileSizeInMB <= requireSize) {
      return 0;
    }
    return fileSizeInMB;
  }

  public static IntentFilter getVideoRecvFilter() {
    return new IntentFilter(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
  }

  public static IntentFilter getImageRecvFilter() {
    return new IntentFilter(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
  }

  public static void clear() {
    SELECTED_MEDIA_COUNT = 0;
    MAX_MEDIA_LIMIT = 0;
  }
}
